<?php
class BrandAction extends Action {
    private $nav = null;
    public function __construct() {
        parent::__construct();
        $this->nav = new NavModel();
    }
    public function index() {
        parent::page();
        $this->tpl->assign('allBrand',$this->model->findAll());
        $this->tpl->display(SMARTY_ADMIN.'brand/show.html');
    }
    public function add() {
        if(isset($_POST['send'])) $this->model->add() ? $this->redirect->succ('?a=brand','品牌新增成功!') : $this->redirect->error('系统出错,品牌新增失败！');
        $this->tpl->display(SMARTY_ADMIN.'brand/add.html');
    }
    public function update() {
        if(isset($_POST['send'])) $this->model->update() ? $this->redirect->succ(Tool::getPrevPage(),'品牌修改成功!') : $this->redirect->error('品牌修改失败!');
        if(isset($_GET['id'])) {
            $this->tpl->assign('oneBrand',$this->model->findOne());
            $this->tpl->display(SMARTY_ADMIN.'brand/update.html');
        }

    }
    public function delete() {
        $this->model->delete() ? $this->redirect->succ(Tool::getPrevPage(),'品牌删除成功!') : $this->redirect->error('系统出错，品牌删除失败!');
    }
    public function ajaxCheckName() {
        $this->model->ajaxCheckName();
    }
}


?>